home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / basupd / curdir$.asm < prev    next >
Assembly Source File  |  1992-09-10  |  3KB  |  84 lines

  1. ;   +----------------------------------------------------------------------+
  2. ;   |                                                                      |
  3. ;   |           BasUpd  Copyright (c) 1992  Thomas G. Hanlin III           |
  4. ;   |                                                                      |
  5. ;   |            See BASUPD.DOC for info on distribution policy            |
  6. ;   |                                                                      |
  7. ;   +----------------------------------------------------------------------+
  8.  
  9.  
  10.  
  11. public  CURDIR
  12.  
  13.  
  14.  
  15. .model medium
  16.  
  17.  
  18.  
  19. .DATA
  20.  
  21.  
  22.  
  23. String    db "x:\"                ; result string (Drive:\PathFromRoot)
  24.           db 64 dup(?)
  25.  
  26. StrHead   dw ?                    ; length of result string
  27.           dw offset DGROUP:String ; pointer to result string
  28.  
  29.  
  30.  
  31. .CODE
  32.  
  33.  
  34.  
  35. CURDIR        proc           far       ; get current subdir on a given drive
  36.               push           bp             ;
  37.               mov            bp,sp          ;
  38.               push           si             ;
  39.               push           di             ;
  40.                                             ;
  41.               push           ds             ;
  42.               pop            es             ;
  43.               xor            dx,dx          ;
  44.               mov            bx,6[bp]       ; drive letter
  45.               mov            cx,[bx]        ;
  46.               mov            bx,2[bx]       ;
  47.               mov            al,[bx]        ;
  48.               or             cx,cx          ; was there really a drive letter?
  49.               jnz            GetSubDir      ;   yep, rock 'n' roll
  50.                                             ;
  51.               mov            ah,19h         ; get default drive
  52.               int            21h            ;
  53.               add            al,"A"         ; convert to letter
  54.                                             ;
  55. GetSubDir:    mov            String,al      ; set drive letter into result
  56.               mov            dl,al          ;
  57.               and            dl,1Fh         ;
  58.               lea            si,DGROUP:String+3
  59.               mov            di,si          ;
  60.               mov            ah,47h         ; get current directory
  61.               int            21h            ;
  62.               jc             Error          ;
  63.               mov            cx,64          ; max subdir length
  64.               mov            al,ch          ;
  65.               repnz          scasb          ; scan up to 64b until NUL
  66.               mov            ax,66          ;
  67.               sub            ax,cx          ;
  68.                                             ;
  69. Done:         mov            StrHead,ax     ; set length of subdir string
  70.                                             ;
  71.               lea            ax,DGROUP:StrHead
  72.               pop            di             ;
  73.               pop            si             ;
  74.               pop            bp             ;
  75.               ret            2              ;
  76.                                             ;
  77. Error:        xor            ax,ax          ; set subdir length to null
  78.               jmp            Done           ;
  79. CURDIR        endp                     ; get current subdir on a given drive
  80.  
  81.  
  82.  
  83.               end
  84.